/**
 * Auto gen via dbpojo-gen.
 */
package com.us.usws.site.console.action;

import java.util.List;

import javax.inject.Inject;

import org.apache.commons.lang3.StringUtils;

import com.us.usws.model.domain.Meeting;
import com.us.usws.service.cud.MeetingCUDService;
import com.us.usws.service.ro.MeetingROService;
import com.us.usws.support.uitls.JSONDataUtil;

/**
 * Struts2 action
 * @author robot
 */
public class MeetingAction extends BasePageSearchAction<Meeting> {

	private static final long serialVersionUID = 1L;

	private Meeting meeting;

	@Inject
	private MeetingROService meetingROService;

	@Inject
	private MeetingCUDService meetingCUDService;

	private String uids;

	/**
	 * ajax load the list of Meeting
	 */
	public void ajaxLoadMeetings() {
		createDataPageUtil();
		List<Meeting> meetings = meetingROService.getMeetings(getStart(), getLimit());
		getOut().println(JSONDataUtil.extJsonSupportPage(meetings, dataPageUtil.getRowCount()));
	}

	/**
	 * ajax update Meeting
	 */
	public void ajaxUpdateMeeting() {
		if (meeting != null) {
			String uid = meeting.getUid();
			if (StringUtils.isNotBlank(uid)) {
				meetingCUDService.updateMeeting(meeting);
			} else {
				meetingCUDService.addMeeting(meeting);
			}
			getOut().print(true);
		} else {
			getOut().print(false);
		}
	}

	/**
	 * ajax delete user.
	 */
	public void ajaxDeleteMeeting() {
		meetingCUDService.deleteMeetingMore(uids);
	}

	public void setMeeting(Meeting meeting) {
		this.meeting = meeting;
	}

	public Meeting getMeeting() {
		return meeting;
	}

	public String getUids() {
		return uids;
	}

	public void setUids(String uids) {
		this.uids = uids;
	}

}